<?
/*
 * 
 * Licensed under the terms of the GNU General Public License:
 * 		http://www.gnu.org/copyleft/gpl.html
 * 
 * For further information visit:
 * 		http://www.auditionrocks.com/
 * 
 * File Authors:
 * 		Andrew Embler (andrew@electricstate.com)
 */

/*
	Filename: base.php
	This file performs two functions:
		
		1. It defines all constants for the web application.
		2. It loads all files in necessary directories (mostly classes/functions)
*/

// Filesystem
ini_set('display_errors',0);
define('BASE_FULL_DIRECTORY', dirname(__FILE__) . '/..');
define('SITE_FULL_DIRECTORY', dirname(__FILE__) . '/..');
// these two constants are interchangeable

define('AUDITION_WEB_DIRECTORY','/audition');
define('LOGIN_PAGE', '/audition/login.php');
define('SYSTEM_DIRECTORY', BASE_FULL_DIRECTORY.AUDITION_WEB_DIRECTORY.'/system');

@include_once(SYSTEM_DIRECTORY.'/configuration.php');

/* ---------- Include Routines ---------- */
define('CLASSES', dirname(__FILE__) . '/classes');

function include_class($class) {
	require_once(CLASSES . '/' . $class . '.php');
}

include_class('db');
include_class('template');
include_class('users');

if (!defined('AUDITION_INSTALLED') && !defined('AUDITION_INSTALLING')) {
	print "Audition does not appear to be installed. Please, visit <b>/audition/system/install.php</b> prior to accessing this page.";
	//$eo->outputErrorPage();
	exit;
}

if (defined('AUDITION_INSTALLED')) {	
	$res = db::connect();
	if (db::isError($res)) {
		$res->outputErrorPage();	
	}
}

require_once(dirname(__FILE__).'/base_lang.php');
define('AUDITION_VERSION', '1.5a1');
define('AUDITION_HELP_SITE', 'http://www.auditionrocks.com/documentation/');
define('USE_MOD_REWRITE', false);
define('TEMPLATES_CSS_DIRECTORY', SITE_WEB_DIRECTORY . '/templates/css');
define('TEMPLATES_IMAGES_DIRECTORY', SITE_WEB_DIRECTORY . '/templates/images');

define('MEDIA_DEFAULT_MAX_WIDTH','640');
define('MEDIA_DEFAULT_MAX_HEIGHT','640');
define('MEDIA_DEFAULT_MAX_THUMBNAIL_WIDTH','80');
define('MEDIA_DEFAULT_MAX_THUMBNAIL_HEIGHT','80');
define('MEDIA_DEFAULT_ORIENTATION','w');
define('MEDIA_BASE_DIRECTORY','/media');
define('MEDIA_ORIGINALS_DIRECTORY',MEDIA_BASE_DIRECTORY . '/originals');
define('MEDIA_INCOMING_DIRECTORY',MEDIA_BASE_DIRECTORY . '/incoming');
define('MEDIA_TYPE_THUMBNAILS',MEDIA_BASE_DIRECTORY . '/generic_thumbnails');
define('MEDIA_EXTENSIONS_ALLOWED','mp3,mp4,wma,ra,wmv,mpg,asf,mov,avi,qt,jpg,jpeg,gif,png,tiff,tif'); // defines, without periods, the extensions that files can have when uploaded. If a file doesn't match an extension, it gets dropped
define('MEDIA_EXTENSIONS_ALLOWED_AV','pls,m3u,mp3,mp4,wma,ra,wmv,mpg,asf,mov,avi,qt');
define('MEDIA_EXTENSIONS_STREAMING', 'mp3'); // what files can be uploaded and then streamed later
define('MEDIA_EXTENSIONS_ALLOWED_PHOTO','jpg,jpeg,gif,png,tiff,tif');
define('MEDIA_EXTENSIONS_ALLOWED', MEDIA_EXTENSIONS_ALLOWED_AV . ',' . MEDIA_EXTENSIONS_ALLOWED_PHOTO); // defines, without periods, the extensions that files can have when uploaded. If a file doesn't match an extension, it gets dropped

// Audio Management. This is different than generalized media - secure, outside of HTTP access
define('AUDIO_DIRECTORY', dirname(__FILE__) . '/../audio/');
define('AUDIO_PSEUDO_DIRECTORY', '/audio');

// Settings
define('VALID_SETTINGS', 'streamingAudioServerURL,streamingAudioFilesPath');


$PHP_SELF = $_SERVER['PHP_SELF']; // because i have legacy code too *sigh*

/* ---------- Handle Session/Login ---------- */
@session_start();
